import {
  mapGetters
} from 'vuex'

export default {
  computed: {
    ...mapGetters('m_cart', ['total'])
  },
  //动态监控tabbar徽章的变化
  watch:{
    total(){
      this.setBadge()
    }
  },
  onShow() {
    this.setBadge()
  },
  methods: {
    //设置tabbar购物车设置数字徽标
    setBadge() {
      uni.setTabBarBadge({
        index: 2,
        text: this.total + '' //text只能是字符串
      })
    }
  }
}
